package com.zhuanzhuan.hero.user.pojo.bo;

import com.zhuanzhuan.hero.member.enums.MemberLevelEnum;
import lombok.Data;

import java.util.List;
import java.util.Objects;

/**
 * @ClassName DisplayIconBO
 * @Description
 * @Author hanjunjun
 * @Date 2024/7/8 16:55
 */
@Data
public class DisplayIconBO {

    private String douyinV;

    private String bmWareHouse;

    private String zhuanzhuanMerchant;

    /**
     * 会员等级图片被隐藏展示的占位图片
     */
    private String memberLevelPicPlaceHolder;

    /**
     * 我的回收单
     */
    private List<MemberLevelIconBO> myRecycleOrder;

    /**
     * 我卖的
     */
    private List<MemberLevelIconBO> mySell;

    /**
     * 访客记录
     */
    private List<MemberLevelIconBO> visitRecord;

    private List<MemberLevelIconBO> contactMobile;

    private List<MemberLevelIconBO> contactWechat;

    private List<MemberLevelIconBO> contactWechatGroup;

    private List<MemberLevelIconBO> contactDouyin;

    @Data
    public static class MemberLevelIconBO {
        /**
         * 会员等级
         * MemberLevelEnum
         */
        private Integer memberLevel;

        private String iconUrl;
    }

    public static String matchIconByMemberLevel(Integer memberLevel, List<MemberLevelIconBO> memberIconList) {
        if (Objects.isNull(memberLevel)) {
            memberLevel = MemberLevelEnum.NORMAL.getCode();
        }
        Integer finalMemberLevel = memberLevel;
        return memberIconList.stream()
            .filter(iconBO -> finalMemberLevel.equals(iconBO.getMemberLevel())).findFirst()
            .orElse(new MemberLevelIconBO())
            .getIconUrl();
    }

}
